import { h, resolveComponent } from 'vue'
import { createRouter, createWebHistory,createWebHashHistory, RouteRecordRaw } from 'vue-router'

const RouteView = {
  render: () => h(resolveComponent('router-view'))
}

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Index',
    component: () => import('@/views/index/index.vue'),
    redirect:'/farmlandData/farmland',
    meta: {
      title: '主页'
    },
    children:[
      {
        path: '/farmlandData/farmland',
        name: 'farmlandData_farmland',
        component: () => import('@/views/farmlandData/farmland.vue'),
        meta: {
          title: '高标准农田',
          icon:require("@/assets/img/routerIcon_0.png"),
          img:require("@/assets/img/routerImg_0.png"),
          index:0
        }
      },
      {
        path: '/farmlandData/quality',
        name: 'farmlandData_quality',
        component: () => import('@/views/farmlandData/quality.vue'),
        meta: {
          title: '耕地质量',
          icon:require("@/assets/img/routerIcon_1.png"),
          img:require("@/assets/img/routerImg_1.png"),
          index:1
        }
      },
      {
        path: '/farmlandData/land',
        name: 'farmlandData_land',
        component: () => import('@/views/farmlandData/land.vue'),
        meta: {
          title: '作物种植',
          icon:require("@/assets/img/routerIcon_2.png"),
          img:require("@/assets/img/routerImg_2.png"),
          index:2
        }
      },
      {
        path: '/device/facility',
        name: 'device_facility',
        component: () => import('@/views/device/facility.vue'),
        meta: {
          title: '设施设备',
          icon:require("@/assets/img/routerIcon_3.png"),
          img:require("@/assets/img/routerImg_3.png"),
          index:4
        }
      },
      {
        path: '/device/monitor',
        name: 'device_monitor',
        component: () => import('@/views/device/monitor.vue'),
        meta: {
          title: '智能监测',
          icon:require("@/assets/img/routerIcon_4.png"),
          img:require("@/assets/img/routerImg_4.png"),
          index:3
        }
      },
      {
        path: '/guidance',
        name: 'guidance',
        component: RouteView,
        meta: {
          title: '农业指导',
          icon:require("@/assets/img/routerIcon_5.png"),
          img:require("@/assets/img/routerImg_5.png"),
          index:5
        },
        children:[
          {
            path: '/guidance/weatherInternational',
            name: 'guidance_weatherInternational',
            component: () => import('@/views/guidance/weatherInternational.vue'),
            meta: {
              title: '气象趋势'
            }
          },
          {
            path: '/guidance/spring',
            name: 'guidance_spring',
            component: () => import('@/views/guidance/spring.vue'),
            meta: {
              title: '春播适宜分析'
            }
          },
          {
            path: '/guidance/autumn',
            name: 'guidance_autumn',
            component: () => import('@/views/guidance/autumn.vue'),
            meta: {
              title: '秋收适宜分析'
            }
          }
        ]
      },
      // {
      //   path: '/irrigate',
      //   name: 'irrigate',
      //   component: RouteView,
      //   meta: {
      //     title: '智能灌溉',
      //     icon:require("@/assets/img/routerIcon_6.png"),
      //     img:require("@/assets/img/routerImg_6.png"),
      //     index:6
      //   },
      //   children:[
      //     {
      //       path: '/irrigate/soil',
      //       name: 'irrigate_soil',
      //       component: () => import('@/views/irrigate/soil.vue'),
      //       meta: {
      //         title: '土壤墒情',
      //       }
      //     },
      //     {
      //       path: '/irrigate/area',
      //       name: 'irrigate_area', 
      //       component: () => import('@/views/irrigate/area.vue'),
      //       meta: {
      //         title: '区域数据'
      //       }
      //     },
      //     {
      //       path: '/irrigate/plot',
      //       name: 'irrigate_plot',
      //       component: () => import('@/views/irrigate/plot.vue'),
      //       meta: {
      //         title: '地块数据'
      //       }
      //     },
      //     {
      //       path: '/irrigate/rank',
      //       name: 'irrigate_rank',
      //       component: () => import('@/views/irrigate/rank.vue'),
      //       meta: {
      //         title: '地块排行'
      //       }
      //     }
      //   ]
      // },
      // {
      //   path: '/patrol/index',
      //   name: 'patrol',
      //   component: () => import('@/views/patrol/index.vue'),
      //   meta: {
      //     title: '巡查管护',
      //     icon:require("@/assets/img/routerIcon_7.png"),
      //     img:require("@/assets/img/routerImg_7.png"),
      //     index:7
      //   }
      // },
      {
        path: '/remote/index',
        name: 'remote_index',
        component: () => import('@/views/remote/index.vue'),
        meta: {
          title: '遥感监测',
          icon:require("@/assets/img/routerIcon_8.png"),
          img:require("@/assets/img/routerImg_8.png"),
          index:8
        }
      }
    ]
  },
  // {
  //   path: '/user/login',
  //   name: 'Login',
  //   component: () => import('../views/login/login.vue')
  // },
  // {
  //   path: '/user/login-callback',
  //   name: 'LoginCallBack',
  //   component: () => import('../views/login/loginCallBack.vue')
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHistory(),
  routes
})

export default router
